import json
import sys

def json2txt(json_file:str, txt_file:str):
    domains_list = []
    with open(json_file, "r") as f_in:
        data = json.load(f_in)
        domains = data["domains"]

        for _ in domains:
            domains_list.append(_["domain"])

    with open(txt_file, "w") as f_out:
        for domain in domains_list:
            f_out.write(domain + "\n")

    print("Done.")

if __name__ == '__main__':
    print("Usage: python json2txt.py input_file.json output_file.txt")
    json2txt(sys.argv[1], sys.argv[2])

    # python json2txt.py 20220211231406.json chinaz-ranking-20220206.txt